<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Embedded scripts</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>

<body>

<div align="center">
<table class=allEncompassingTable >
 <tr>
  <td >
<p><a href="../index.html" TARGET="_top"><img src="images/homeImg.png"></a></p>



<h1>Embedded scripts</h1>

<p>CoppeliaSim is a highly customizable simulator: almost every step of a <a href="simulation.htm">simulation</a> is user-defined. This flexibility is allowed through an integrated script interpreter. The scripting language is <a href="http://www.lua.org">Lua</a>, which is an extension programming language designed to support general procedural programming. For more information on Lua, refer to the <a href="luaCrashCourse.htm">Lua crash course</a> section and the <a href="http://www.lua.org">online documentation</a>. By default, CoppeliaSim uses the official and original Lua, but if you wish you can tell CoppeliaSim to use another flavor of Lua by setting variable <em>useExternalLuaLibrary</em> in <em>system/usrset.txt</em> to <em>true</em>. In that case, all Lua calls are handled via the <em>simLua</em> library, which itself will link against <a href="http://luajit.org/">LuaJIT</a> (Lua Just-in-Time compiler). The <em>simLua</em> library project files are located <a href="https://github.com/CoppeliaRobotics/simLuaLibrary" target="_blank">here</a>. See <a href="acknowledgments.htm">here</a> for acknowledgments and credits related to Lua and LuaJIT.<br>
</p>

<p align=center><img src="images/luaLogo.jpg"></p>
<p class=imageLabel>[Lua logo]</p>
<br>

<p>CoppeliaSim extends Lua's commands and adds CoppeliaSim specific commands that can be recognized by their <em>sim</em>-prefixes (e.g. <a href="regularApi/simHandleCollision.htm">sim.handleCollision</a>). For a list of all CoppeliaSim specific Lua-commands, refer to the <a href="apiOverview.htm">regular API</a>. New, customized Lua-commands can also be registered from the <a href="mainClientApplication.htm">main client application</a> or from a <a href="plugins.htm">plugin</a>. Refer to the <a href="apiFunctionListCategory.htm#customizingLuaFunctions">related API-functions</a> for more information.<br>
</p>

<p>Lua's functionality itself can easily be extended by making use of a <a href="http://lua-users.org/wiki/LibrariesAndBindings">Lua extension library available online</a>.<br>
</p>

<p>An embedded script is a script that is embedded in a <a href="scenes.htm">scene</a> (or <a href="models.htm">model</a>), i.e. a script that is part of the scene and that will be saved and loaded together with the rest of the scene (or model). There are different types of embedded scripts that are supported. Each type has specific features and application areas:</p>

<p align=center><img src="images/embeddedScripts.jpg"></p>
<p class=imageLabel>[Embedded script types]</p>
<br>

<p>Two major types of embedded scripts are supported: </p>

<li><strong><a href="simulationScripts.htm">Simulation scripts</a></strong>: simulation scripts are scripts that are executed only during simulation, and that are used to customize a simulation or a simulation model. The main simulation loop is handled via the <a href="mainScript.htm">main script</a>, and models/robots are controlled via <a href="childScripts.htm">child scripts</a>.</li>

<li><strong><a href="customizationScripts.htm">Customization scripts</a></strong>: those are scripts that can also be executed while simulation is not running, and that are used to customize a simulation scene or the simulator itself.</li>





<br>

<p>Next to embedded scripts, CoppeliaSim supports also <a href="addOns.htm">add-ons</a> and <a href="sandboxScript.htm">the sandbox script</a>, that allow to provide a specific functionality which is not linked to a specific scene or model.</p>


<p>Among the different script types, it can be useful to remember that some are associated with <a href="objects.htm">scene objects</a> (attached to scene objects, i.e. <em>associated</em> scripts) such as child scripts, joint control callback scripts and customization scripts, and others are unassociated (i.e. <em>unassociated</em> scripts). Associated scripts, which form the basis of CoppeliaSim's distributed control architecture, share the convenient property to be automatically duplicated if their associated object is duplicated.</p>
<p>CoppeliaSim scripts may be published under any license.</p>


<br>
<h3 class=recommendedTopics>Recommended topics</h3>
<li><a href="simulationScripts.htm">Simulation scripts</a></li>
<li><a href="customizationScripts.htm">Customization scripts</a></li>
<li><a href="addOns.htm">Add-ons</a></li>
<li><a href="sandboxScript.htm">The sandbox script</a></li>
<li><a href="scriptProperties.htm">Script dialog</a></li>
<li><a href="scriptEditor.htm">Script editor</a></li>
<li><a href="accessingGeneralObjects.htm">Accessing objects programmatically</a></li>
<li><a href="apiOverview.htm">Application Programming Interface</a></li>
<br>
<br>
 </tr>
</table> 
</div>  
  
  
</body>

</html>
